package com.yeyks.other.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.yeyks.common.base.PageResult;
import com.yeyks.other.dal.domain.Carousel;
import com.yeyks.other.dal.dao.CarouselMapper;
import com.yeyks.other.dto.CarouselListParam;
import com.yeyks.other.service.CarouselService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 * 轮播图 服务实现类
 * </p>
 *
 * @author yun
 * @since 2019-12-25
 */
@Service
public class CarouselServiceImpl extends ServiceImpl<CarouselMapper, Carousel> implements CarouselService {

    /**
     * 列表查询
     *
     * @param param
     * @return
     */
    @Override
    public PageResult<Carousel> myList(CarouselListParam param) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<Carousel> carousels = baseMapper.selectList(new QueryWrapper<Carousel>()
                .eq(Carousel.STATUS, param.getStatus())
                .eq(Carousel.TYPE, param.getType()));
        return PageResult.getPageResult(carousels);
    }

    /**
     * 通过类型和状态查询
     *
     * @param status {@link Carousel}
     * @param type   {@link Carousel}
     * @return
     */
    @Override
    public List<Carousel> myList(Integer status, Integer type) {
        return baseMapper.selectList(new QueryWrapper<Carousel>()
                .eq(Carousel.STATUS, status)
                .eq(Carousel.TYPE, type));
    }
}
